/**
 * 
 */
package megamek.common.actions;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.util.ArrayList;

import junit.framework.TestCase;
import megamek.common.Aero;
import megamek.common.BombType;
import megamek.common.Entity;
import megamek.common.EquipmentType;
import megamek.common.IAimingModes;
import megamek.common.IGame;
import megamek.common.Mounted;

/**
 * @author Ruchi
 *
 */
public class WeaponAttackActionTest extends TestCase {
        WeaponAttackAction attack1;
    WeaponAttackAction attack2;
    private int num;

    IGame game;

        /**
         * @throws java.lang.Exception
         */
        @Before
        public void setUp() throws Exception {
                attack1 = new WeaponAttackAction(1, 2, 3);
        attack2 = new WeaponAttackAction(1, 2, 3, 4);
        num = 5;
        }

        /**
         * @throws java.lang.Exception
         */
        @After
        public void tearDown() throws Exception {
        }


    /**
     * Test method for
     * {@link megamek.common.actions.WeaponAttackAction#getWeaponId()}.
     */
    @Test
    public void testGetWeaponId()
    {
            assertEquals(3, attack1.getWeaponId());
            assertEquals(4, attack2.getWeaponId());
    }



    /**
     * Test method for
     * {@link megamek.common.actions.WeaponAttackAction#getAmmoId()}.
     */
    @Test
    public void testGetAmmoId()
    {
            assertEquals(-1, attack1.getAmmoId());
            assertEquals(-1, attack2.getAmmoId());
    }



    /**
     * Test method for
     * {@link megamek.common.actions.WeaponAttackAction#getAimedLocation()}.
     */
    @Test
    public void testGetAimedLocation()
    {
            int x = Entity.LOC_NONE;
            assertEquals(x, attack1.getAimedLocation());
            assertEquals(x, attack2.getAimedLocation());
    }



    /**
     * Test method for
     * {@link megamek.common.actions.WeaponAttackAction#getAimingMode()}.
     */
    @Test
    public void testGetAimingMode()
    {
            int x = IAimingModes.AIM_MODE_NONE;
            assertEquals(x, attack1.getAimingMode());
            assertEquals(x, attack2.getAimingMode());
    }



    /**
     * Test method for
     * {@link megamek.common.actions.WeaponAttackAction#setWeaponId(int)}.
     */
    @Test
    public void testSetWeaponId()
    {
            attack1.setWeaponId(num);
            attack2.setWeaponId(num);

            assertEquals(5, attack1.getWeaponId());
            assertEquals(5, attack2.getWeaponId());
    }



    /**
     * Test method for
     * {@link megamek.common.actions.WeaponAttackAction#setAmmoId(int)}.
     */
    @Test
    public void testSetAmmoId()
    {
            attack1.setAmmoId(num);
            attack2.setAmmoId(num);

            assertEquals(5, attack1.getAmmoId());
            assertEquals(5, attack2.getAmmoId());
    }



    /**
     * Test method for
     * {@link megamek.common.actions.WeaponAttackAction#setAimedLocation(int)}.
     */
    @Test
    public void testSetAimedLocation()
    {
            attack1.setAimedLocation(num);
            assertEquals(5, attack1.getAimedLocation());
    }



    /**
     * Test method for
     * {@link megamek.common.actions.WeaponAttackAction#setAimingMode(int)}.
     */
    @Test
    public void testSetAimingMode()
    {
            attack1.setAimingMode(num);
            assertEquals(5, attack1.getAimingMode());
    }



    /**
     * Test method for
     * {@link megamek.common.actions.WeaponAttackAction#addCounterEquipment(megamek.common.Mounted)}
     * .
     */
    @Test
    public void testAddCounterEquipment()
    {
            Mounted m = new Mounted(new Aero(), new EquipmentType());
            attack1.addCounterEquipment(m);

            ArrayList<Mounted> mArr = new ArrayList<Mounted>();
            mArr.add(m);

            assertEquals(mArr, attack1.getCounterEquipment());
    }



    /**
     * Test method for
     * {@link megamek.common.actions.WeaponAttackAction#setOtherAttackInfo(int)}
     * .
     */
    @Test
    public void testSetOtherAttackInfo()
    {
            attack1.setOtherAttackInfo(num);
            assertEquals(5, attack1.getOtherAttackInfo());
    }



    /**
     * Test method for
     * {@link megamek.common.actions.WeaponAttackAction#getOtherAttackInfo()}.
     */
    @Test
    public void testGetOtherAttackInfo()
    {
            assertEquals(-1, attack1.getOtherAttackInfo());
    }



    /**
     * Test method for
     * {@link megamek.common.actions.WeaponAttackAction#toHit(megamek.common.IGame)}
     * .
     */
    @Test
    public void testToHitIGame()
    {
            fail("Not yet implemented");
            // attack1.toHit(game);
    }



    /**
     * Test method for
     * {@link megamek.common.actions.WeaponAttackAction#toHit(megamek.common.IGame, int, megamek.common.Targetable, int)}
     * .
     */
    @Test
    public void testToHitIGameIntTargetableInt()
    {
            fail("Not yet implemented");
            // attack1
            // attack2
    }



    /**
     * Test method for
     * {@link megamek.common.actions.WeaponAttackAction#toHit(megamek.common.IGame, int, megamek.common.Targetable, int, int, int)}
     * .
     */
    @Test
    public void testToHitIGameIntTargetableIntIntInt()
    {
            fail("Not yet implemented");
            // attack1
            // attack2
    }



    /**
     * Test method for
     * {@link megamek.common.actions.WeaponAttackAction#setNemesisConfused(boolean)}
     * .
     */
    @Test
    public void testSetNemesisConfused()
    {
            attack1.setNemesisConfused(true);
            assertTrue(attack1.isNemesisConfused());
    }



    /**
     * Test method for
     * {@link megamek.common.actions.WeaponAttackAction#setSwarmingMissiles(boolean)}
     * .
     */
    @Test
    public void testSetSwarmingMissiles()
    {
            attack1.setSwarmingMissiles(true);
            assertTrue(attack1.isSwarmingMissiles());
    }



    /**
     * Test method for
     * {@link megamek.common.actions.WeaponAttackAction#setSwarmMissiles(int)}.
     */
    @Test
    public void testSetSwarmMissiles()
    {
            attack1.setSwarmMissiles(1);
            assertEquals(1, attack1.getSwarmMissiles());
    }



    /**
     * Test method for
     * {@link megamek.common.actions.WeaponAttackAction#setBombPayload(int[])}.
     */
    @Test
    public void testSetBombPayload()
    {
        int[] tempBombType = new int[BombType.B_NUM];
        for (int i = 0; i<BombType.B_NUM; i++)
        {
                tempBombType[i] = 1;
        }
        
        attack1.setBombPayload(tempBombType);
        assertArrayEquals(tempBombType, attack1.getBombPayload());
        
    }

}